Skip to content

feat: add source/cdc change-event codec#133

Merged
joshua-temple merged 1 commit into
mainfrom
feat/source-cdc
Jun 4, 2026
Merged

feat: add source/cdc change-event codec#133
joshua-temple merged 1 commit into
mainfrom
feat/source-cdc

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

What this change does

Adds source/cdc, a change-data-capture codec for the source seam (one of the four roadmap items from #131). It decodes the Debezium / OpenCDC JSON change-event envelope into a typed ChangeEvent:

  • an Operation enum (create/update/delete/read/tombstone),
  • deferred before/after row images projected on demand via BeforeAs / AfterAs,
  • decoded source metadata (SourceHeaders) and the commit timestamp.

Tombstones decode to OpTombstone; malformed envelopes return a *DecodeError so they route as poison rather than crashing the consume loop.

Why

CDC turns a database into an event source, and the envelope is effectively a standard, so decoding it belongs in the suite rather than in every consumer. It ships as a stdlib-only subpackage of the source module alongside retry/dlq (no new dependency), with a memsource consume test and a CDC-driven Drive example in source/statemachine showing a change event driving a statechart. Native WAL connectors stay future work; this is the decode layer they'd feed.

Relates to: follows up the source Tier-1 PR (#131).

Checklist

  • Commits are signed off (git commit -s) per the DCO
  • Conventional commit messages (type: subject)
  • Tests added (table-driven unit + consume + statemachine example); 95.8% coverage
  • Public API documented (godoc + Example tests + codecs docs page)
  • mage check runs in CI across the workspace

Decode the Debezium/OpenCDC JSON change-event envelope into a typed
ChangeEvent (Operation enum, deferred before/after row images, decoded
source metadata, commit timestamp) with BeforeAs/AfterAs projection and
SourceHeaders. Tombstones decode to OpTombstone; malformed envelopes
return *DecodeError (poison). Ships as a stdlib subpackage of the source
module alongside retry/dlq, with a memsource consume test and a CDC-driven
Drive example in source/statemachine. Native WAL connectors stay future
work.

Signed-off-by: Joshua Temple <[email protected]>
@joshua-temple joshua-temple merged commit d47a728 into main Jun 4, 2026
119 checks passed
@joshua-temple joshua-temple deleted the feat/source-cdc branch June 4, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant